<?php
    class rssdb
    {
        
        public function Show($url = "http://vnexpress.net/rss/gl/trang-chu.rss", $get = '')
        {
            $list_des[] = array();
            $list_title[] = array();
            
            $dom = new DOMDocument('1.0','utf-8'); //tao doi tuong dom 
            $dom->load($url);//muon lay rss tu trang nao thi ban khai bao day 
            $items = $dom->getElementsByTagName("item");//lay cac element co tag name la item va gan vao bien $items 
            foreach($items as $item)//lap 
            { 
                $titles=$item->getElementsByTagName('title');//lay cac element co tag name la title va gan vao bien $titles 
                $title=$titles->item(0);//lay ra gia tri dau tuien trong array $titles 
                $descriptions=$item->getElementsByTagName('description'); 
                $des=$descriptions->item(0); 
                $links=$dom->getElementsByTagName('link'); 
                $link=$links->item(0);
                
                $list_title[] = $title->nodeValue;
                $list_des[] = $des->nodeValue;
            }
            if($get == '')
                return $list_des;
            else
                return $list_title;
        }
    }
?>